package com.icinfo.cloud.provider.punish.service.impl;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.icinfo.cloud.common.core.Constant.Constant;
import com.icinfo.cloud.provider.common.utils.HeaderUtil;
import com.icinfo.cloud.provider.punish.service.ICaseExecuteService;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.dto.CasePunishActionDto;
import com.icinfo.framework.common.web.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author ChenHan
 * @date 2022/12/6 15:36
 **/
@Service
public class ICaseExecuteServiceImpl implements ICaseExecuteService {

    @Value("${tzService.url}")
    private String url;


    /**
     * 保存执行决定
     *
     * @param casePunishActionDto
     * @return
     * @author 陈汉
     * @date 2022年12月6日15:33:11
     */
    @Override
    public Result punishAction(CasePunishActionDto casePunishActionDto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
//        casePunishActionDto.setRequestSource(Constant.STRING_1);
        String param = JSON.toJSONString(casePunishActionDto);
        String response = HttpUtil.createPost(url.concat("/execute/punishAction")).addHeaders(headers).body(param).execute().body();
        Result<String> result = JSON.parseObject(response, Result.class);
        return result;
    }
}
